﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ContractDetails.ascx.cs" Inherits="TravelSite.Controls.ContractDetails" %>

<script type="text/javascript">
    $(function () {
            $("#contractDialog").dialog({ modal: true, autoOpen: false, width: 950, resizable: false });
            $("#contractDialog").parent().appendTo(jQuery("form:first"));

            <% if (Roles.IsUserInRole("admin")) { %>
                $("#ccDialog").dialog({ autoOpen: false, width: 950, resizable: false });
                $("#ccDialog").parent().appendTo(jQuery("form:first"));
            <% } %>

            $("#fieldDialog").dialog({ autoOpen: false, width: 800, resizable: false });
            $("#fieldDialog").parent().appendTo(jQuery("form:first"));

            $(".ui-dialog-titlebar").hide();

            Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function (evt, args) {
                $.datepicker.setDefaults($.datepicker.regional[""]);
                $("#<%= txtExpDate.ClientID %>").datepicker($.datepicker.regional["en-GB"]);

                $("#<%= txtExpDate.ClientID %>").datepicker({
                    showmonth: true,
                    autoSize: true,
                    showAnim: 'slideDown',
                    duration: 'fast'
                });
                $("#btnShowDate").click(function () {
                    $("#<%= txtExpDate.ClientID %>").datepicker('show');
                });
            });
            
        });

        function createContractForm(id) {
            __doPostBack('upContract', id);
        }

        function openContract(flag) {
            $('#contractDialog').dialog('open');
            /*$("#contractDialog :input").attr("disabled", flag);
            if (flag) {
                $("#btnSave").hide();
            }
            else {
                $("#btnSave").show();
            }*/
            $("#<%= btnCancel.ClientID %>").attr("disabled", false);
        }

        function showFieldDialog(fieldName, contactColumn) {
            $('#tbTemplateFieldName').val(fieldName);
            $('#tbTemplateFieldName').attr("readonly", "readonly");
            if (contactColumn != '')
                $('#ddlContactColumnName').val(contactColumn)
            else
                $('#ddlContactColumnName').find('option:first').prop('selected', 'selected');

            $('#fieldDialog').dialog('open');
        }

        <% if (Roles.IsUserInRole("admin")) { %>
        function showCCDialog(id) {
            __doPostBack('upCC', id);
        }

        function openCC() {
            $('#ccDialog').dialog('open');
        }
        <% } %>
</script>

<div id="contractDialog">
            <asp:UpdatePanel runat="server" ID="upContract" OnLoad="upContract_Load" UpdateMode="Conditional" ClientIDMode="Static">
            <ContentTemplate>
                <div class="row">
                    <div class="fieldset_block col-lg-12 page_area">
                        <fieldset>
                            <legend><h4><asp:Label runat="server" ID="lblDialogTitle"></asp:Label></h4></legend>
                            <asp:Label runat="server" ID="hdId" style="display:none;" />
                            <div class="fieldset_cotent form-horizontal">
                                <div class="row">
                                    <div class="col-lg-12">                                    
                                        <div class="form-group">
                                            <label class="col-lg-4 control-label">Travel Package</label>
                                            <div class="col-lg-8">
                                                <asp:DropDownList CssClass="form-control" ID="ddlPackageId" runat="server" DataValueField="PackageId" DataTextField="PackageName"/>
                                             </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg-12">                                    
                                        <div class="form-group">
                                            <label class="col-lg-4 control-label">Exp Date</label>
                                            <div class="col-lg-8">
                                                <div class="input-group">   
                                                    <asp:TextBox ID="txtExpDate" CssClass="form-control" ValidationGroup="newContractItem" runat="server" placeholder="Exp Date"></asp:TextBox>
                                                    <span class="input-group-btn">
                                                        <button class="btn btn-default" type="button" id="btnShowDate">
                                                            <img src="<%=ResolveClientUrl("~") %>images/calander_icon.png" alt="calander" title="Calander" />
                                                        </button>
                                                    </span>
                                                </div>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="txtExpDate" runat="server" Text="*" ValidationGroup="newContractItem" ForeColor="Red" Display="Dynamic" />
                                             </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg-12">                                    
                                        <div class="form-group">
                                            <label class="col-lg-4 control-label">Contract Template</label>
                                            <div class="col-lg-8">
                                                <asp:DropDownList CssClass="form-control" ID="ddlTemplateId" runat="server" DataValueField="TemplateId" DataTextField="FileName" AutoPostBack="true" OnSelectedIndexChanged="ddlTemplateId_SelectedIndexChanged"/>
                                             </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg-12">                                    
                                    <div class="form-group">
                                        <label class="col-lg-3 control-label">Credit Card Number</label>
                                        <div class="col-lg-3">
                                            <asp:TextBox CssClass="form-control" placeholder="Credit Card Number" ID="txtCardNumber" ValidationGroup="newContractItem" runat="server" />
                                        </div>
                                        <label class="col-lg-3 control-label">Credit Card Exp.Date</label>
                                        <div class="col-lg-3">
                                            <asp:TextBox CssClass="form-control" placeholder="Credit Card Exp.Date" ID="txtCardDate" ValidationGroup="newContractItem" runat="server" />
                                        </div>
                                    </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg-12">                                    
                                    <div class="form-group">
                                        <label class="col-lg-3 control-label">Credit Card CVV Code</label>
                                        <div class="col-lg-3">
                                            <asp:TextBox CssClass="form-control" placeholder="Credit Card CVV Code" ID="txtCardCVV" ValidationGroup="newContractItem" runat="server" />
                                        </div>
                                        <label class="col-lg-3 control-label">Credit Card Auth Code</label>
                                        <div class="col-lg-3">
                                            <asp:TextBox CssClass="form-control" placeholder="Credit Card Auth Code" ID="txtCardCC" ValidationGroup="newContractItem" runat="server" />
                                        </div>
                                    </div>
                                    </div>
                                </div>

                                <div class="row">
                                <asp:Repeater runat="server" ID="rptDetails" OnItemDataBound="rptDetails_ItemDataBound" >
                                    <ItemTemplate>
                                            <div class="col-lg-12">                                    
                                                <div class="form-group">
                                                    <div class="col-lg-2" style="text-align:right;vertical-align:middle;">
                                                        <asp:Label runat="server" ID="lblFieldName" class="btn" Text='<%# Eval("FieldName")%>' />
                                                    </div>
                                                    <div class="col-lg-2">
                                                        <asp:Button runat="server" ID="btnField" class="btn col-lg-12" Text='<%# Eval("ContactColumnCaption")%>' style="text-align:left;"  />
                                                    </div>
                                                    <div class="col-lg-8">
                                                        <asp:TextBox CssClass="form-control" ID="txtContactFieldValue" runat="server" Text='<%# Eval("ContactColumnValue")%>' />
                                                    </div>
                                                </div>
                                            </div>
                                    </ItemTemplate>
                                </asp:Repeater>
                                </div>

                                <div class="button_group">
                                    <asp:Button CssClass="btn btn-success" ID="btnSave"  ValidationGroup="newContractItem" Text="Save Draft" runat="server" OnClick="btnSave_Click" />
                                    <asp:Button CssClass="btn btn-warning" ID="btnSend"  ValidationGroup="newContractItem" Text="Send" runat="server" OnClick="btnSend_Click" />
                                    
                                    <button class="btn btn-info" type="button" style="display:none;">Preview</button>                    

                                    <asp:Button CssClass="btn btn-info" ID="btnCancel" Text="Cancel" runat="server" OnClientClick="$('#contractDialog').dialog('close'); return false;"  />
                                </div>
                            </div>
                        </fieldset>
                    </div>
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
            </Triggers>
            </asp:UpdatePanel>
</div> 

<div id="fieldDialog" class="row">
            <asp:UpdatePanel runat="server" ID="upField" UpdateMode="Conditional" ClientIDMode="Static">
            <ContentTemplate>
                <div class="fieldset_block col-lg-9 page_area" style="width:100%;">
                <fieldset>
                    <legend><h4>Field Mapping</h4></legend>
                    <div class="fieldset_cotent form-horizontal">
                        <div class="row">
                            <div class="col-lg-12">                                    
                                <div class="form-group">
                                    <label class="col-lg-4 control-label">Template Field Name</label>
                                    <div class="col-lg-6">
                                        <asp:TextBox ID="tbTemplateFieldName" runat="server" CssClass="form-control" ClientIDMode="Static"></asp:TextBox>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-4 control-label">Contact Attribute</label>
                                    <div class="col-lg-6">
                                        <asp:DropDownList CssClass="form-control" ID="ddlContactColumnName" runat="server" DataValueField="ContactColumnName" DataTextField="ContactColumnFriendlyName" ClientIDMode="Static"/>    
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="button_group">
                            <asp:Button CssClass="btn btn-success" ID="btnSaveField"  ValidationGroup="changePassword" Text="Ok" runat="server" OnClick="btnSaveField_Click" />
                            <asp:Button CssClass="btn btn-info" ID="btnCancelField" Text="Cancel" runat="server" OnClientClick="$('#fieldDialog').dialog('close'); return false;" CausesValidation="false" />
                        </div> 
                    </div>
                </fieldset>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnSaveField" EventName="Click"  />
            </Triggers>
            </asp:UpdatePanel>
</div>

<% if (Roles.IsUserInRole("admin"))
{ %>
<div id="ccDialog">
            <asp:UpdatePanel runat="server" ID="upCC" OnLoad="upCC_Load" UpdateMode="Conditional" ClientIDMode="Static">
            <ContentTemplate>
                <div class="row">
                    <div class="fieldset_block col-lg-12 page_area">
                        <fieldset>
                            <legend><h4>Credit Card Info</h4></legend>
                            <div class="fieldset_cotent form-horizontal">
                                <div class="row">
                                    <div class="col-lg-12">                                    
                                    <div class="form-group">
                                        <label class="col-lg-3 control-label">Credit Card Number</label>
                                        <div class="col-lg-3">
                                            <asp:TextBox CssClass="form-control" placeholder="Credit Card Number" ID="txtCardNumberD" runat="server" ReadOnly="true" />
                                        </div>
                                        <label class="col-lg-3 control-label">Credit Card Exp.Date</label>
                                        <div class="col-lg-3">
                                            <asp:TextBox CssClass="form-control" placeholder="Credit Card Exp.Date" ID="txtCardDateD" runat="server" ReadOnly="true" />
                                        </div>
                                    </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg-12">                                    
                                    <div class="form-group">
                                        <label class="col-lg-3 control-label">Credit Card CVV Code</label>
                                        <div class="col-lg-3">
                                            <asp:TextBox CssClass="form-control" placeholder="Credit Card CVV Code" ID="txtCardCVVD" runat="server" ReadOnly="true" />
                                        </div>
                                        <label class="col-lg-3 control-label">Credit Card Auth Code</label>
                                        <div class="col-lg-3">
                                            <asp:TextBox CssClass="form-control" placeholder="Credit Card Auth Code" ID="txtCardCCD" runat="server" ReadOnly="true" />
                                        </div>
                                    </div>
                                    </div>
                                </div>
                            
                                <div class="button_group">
                                    <asp:Button CssClass="btn btn-info" ID="btnCancelCC" Text="Close" runat="server" OnClientClick="$('#ccDialog').dialog('close'); return false;" />
                                </div>
                            </div>
                        </fieldset>
                    </div>
                </div>
            </ContentTemplate>
            <Triggers>
            </Triggers>
            </asp:UpdatePanel>
</div> 
<% } %>